/**
 */
package DentalClinicEMF.clinic.impl;

import DentalClinicEMF.clinic.Appointment;
import DentalClinicEMF.clinic.Client;
import DentalClinicEMF.clinic.ClientType;
import DentalClinicEMF.clinic.ClinicPackage;
import DentalClinicEMF.clinic.DentalClinic;
import DentalClinicEMF.clinic.Dentist;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Client</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link DentalClinicEMF.clinic.impl.ClientImpl#getName <em>Name</em>}</li>
 *   <li>{@link DentalClinicEMF.clinic.impl.ClientImpl#getAddress <em>Address</em>}</li>
 *   <li>{@link DentalClinicEMF.clinic.impl.ClientImpl#getAge <em>Age</em>}</li>
 *   <li>{@link DentalClinicEMF.clinic.impl.ClientImpl#getDeltaID <em>Delta ID</em>}</li>
 *   <li>{@link DentalClinicEMF.clinic.impl.ClientImpl#getClientType <em>Client Type</em>}</li>
 *   <li>{@link DentalClinicEMF.clinic.impl.ClientImpl#getEReference0 <em>EReference0</em>}</li>
 *   <li>{@link DentalClinicEMF.clinic.impl.ClientImpl#getEReference1 <em>EReference1</em>}</li>
 *   <li>{@link DentalClinicEMF.clinic.impl.ClientImpl#getEReference2 <em>EReference2</em>}</li>
 *   <li>{@link DentalClinicEMF.clinic.impl.ClientImpl#getPreferredDentist <em>Preferred Dentist</em>}</li>
 *   <li>{@link DentalClinicEMF.clinic.impl.ClientImpl#getCAppointments <em>CAppointments</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ClientImpl extends MinimalEObjectImpl.Container implements Client {
	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The default value of the '{@link #getAddress() <em>Address</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAddress()
	 * @generated
	 * @ordered
	 */
	protected static final String ADDRESS_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getAddress() <em>Address</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAddress()
	 * @generated
	 * @ordered
	 */
	protected String address = ADDRESS_EDEFAULT;

	/**
	 * The default value of the '{@link #getAge() <em>Age</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAge()
	 * @generated
	 * @ordered
	 */
	protected static final int AGE_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getAge() <em>Age</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAge()
	 * @generated
	 * @ordered
	 */
	protected int age = AGE_EDEFAULT;

	/**
	 * The default value of the '{@link #getDeltaID() <em>Delta ID</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDeltaID()
	 * @generated
	 * @ordered
	 */
	protected static final int DELTA_ID_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getDeltaID() <em>Delta ID</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDeltaID()
	 * @generated
	 * @ordered
	 */
	protected int deltaID = DELTA_ID_EDEFAULT;

	/**
	 * The default value of the '{@link #getClientType() <em>Client Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getClientType()
	 * @generated
	 * @ordered
	 */
	protected static final ClientType CLIENT_TYPE_EDEFAULT = ClientType.DELTACARE_LITERAL;

	/**
	 * The cached value of the '{@link #getClientType() <em>Client Type</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getClientType()
	 * @generated
	 * @ordered
	 */
	protected ClientType clientType = CLIENT_TYPE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getEReference0() <em>EReference0</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEReference0()
	 * @generated
	 * @ordered
	 */
	protected Client eReference0;

	/**
	 * The cached value of the '{@link #getEReference1() <em>EReference1</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEReference1()
	 * @generated
	 * @ordered
	 */
	protected Client eReference1;

	/**
	 * The cached value of the '{@link #getEReference2() <em>EReference2</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEReference2()
	 * @generated
	 * @ordered
	 */
	protected Client eReference2;

	/**
	 * The cached value of the '{@link #getPreferredDentist() <em>Preferred Dentist</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPreferredDentist()
	 * @generated
	 * @ordered
	 */
	protected Dentist preferredDentist;

	/**
	 * The cached value of the '{@link #getCAppointments() <em>CAppointments</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCAppointments()
	 * @generated
	 * @ordered
	 */
	protected Appointment cAppointments;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ClientImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EClass eStaticClass() {
		return ClinicPackage.Literals.CLIENT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ClinicPackage.CLIENT__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getAddress() {
		return address;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setAddress(String newAddress) {
		String oldAddress = address;
		address = newAddress;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ClinicPackage.CLIENT__ADDRESS, oldAddress, address));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getAge() {
		return age;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setAge(int newAge) {
		int oldAge = age;
		age = newAge;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ClinicPackage.CLIENT__AGE, oldAge, age));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getDeltaID() {
		return deltaID;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDeltaID(int newDeltaID) {
		int oldDeltaID = deltaID;
		deltaID = newDeltaID;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ClinicPackage.CLIENT__DELTA_ID, oldDeltaID, deltaID));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ClientType getClientType() {
		return clientType;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setClientType(ClientType newClientType) {
		ClientType oldClientType = clientType;
		clientType = newClientType == null ? CLIENT_TYPE_EDEFAULT : newClientType;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ClinicPackage.CLIENT__CLIENT_TYPE, oldClientType, clientType));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Client getEReference0() {
		if (eReference0 != null && eReference0.eIsProxy()) {
			InternalEObject oldEReference0 = (InternalEObject)eReference0;
			eReference0 = (Client)eResolveProxy(oldEReference0);
			if (eReference0 != oldEReference0) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, ClinicPackage.CLIENT__EREFERENCE0, oldEReference0, eReference0));
			}
		}
		return eReference0;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Client basicGetEReference0() {
		return eReference0;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setEReference0(Client newEReference0) {
		Client oldEReference0 = eReference0;
		eReference0 = newEReference0;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ClinicPackage.CLIENT__EREFERENCE0, oldEReference0, eReference0));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Client getEReference1() {
		if (eReference1 != null && eReference1.eIsProxy()) {
			InternalEObject oldEReference1 = (InternalEObject)eReference1;
			eReference1 = (Client)eResolveProxy(oldEReference1);
			if (eReference1 != oldEReference1) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, ClinicPackage.CLIENT__EREFERENCE1, oldEReference1, eReference1));
			}
		}
		return eReference1;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Client basicGetEReference1() {
		return eReference1;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setEReference1(Client newEReference1) {
		Client oldEReference1 = eReference1;
		eReference1 = newEReference1;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ClinicPackage.CLIENT__EREFERENCE1, oldEReference1, eReference1));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Client getEReference2() {
		if (eReference2 != null && eReference2.eIsProxy()) {
			InternalEObject oldEReference2 = (InternalEObject)eReference2;
			eReference2 = (Client)eResolveProxy(oldEReference2);
			if (eReference2 != oldEReference2) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, ClinicPackage.CLIENT__EREFERENCE2, oldEReference2, eReference2));
			}
		}
		return eReference2;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Client basicGetEReference2() {
		return eReference2;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setEReference2(Client newEReference2) {
		Client oldEReference2 = eReference2;
		eReference2 = newEReference2;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ClinicPackage.CLIENT__EREFERENCE2, oldEReference2, eReference2));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Dentist getPreferredDentist() {
		return preferredDentist;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetPreferredDentist(Dentist newPreferredDentist, NotificationChain msgs) {
		Dentist oldPreferredDentist = preferredDentist;
		preferredDentist = newPreferredDentist;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ClinicPackage.CLIENT__PREFERRED_DENTIST, oldPreferredDentist, newPreferredDentist);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPreferredDentist(Dentist newPreferredDentist) {
		if (newPreferredDentist != preferredDentist) {
			NotificationChain msgs = null;
			if (preferredDentist != null)
				msgs = ((InternalEObject)preferredDentist).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ClinicPackage.CLIENT__PREFERRED_DENTIST, null, msgs);
			if (newPreferredDentist != null)
				msgs = ((InternalEObject)newPreferredDentist).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ClinicPackage.CLIENT__PREFERRED_DENTIST, null, msgs);
			msgs = basicSetPreferredDentist(newPreferredDentist, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ClinicPackage.CLIENT__PREFERRED_DENTIST, newPreferredDentist, newPreferredDentist));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Appointment getCAppointments() {
		return cAppointments;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetCAppointments(Appointment newCAppointments, NotificationChain msgs) {
		Appointment oldCAppointments = cAppointments;
		cAppointments = newCAppointments;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ClinicPackage.CLIENT__CAPPOINTMENTS, oldCAppointments, newCAppointments);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setCAppointments(Appointment newCAppointments) {
		if (newCAppointments != cAppointments) {
			NotificationChain msgs = null;
			if (cAppointments != null)
				msgs = ((InternalEObject)cAppointments).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ClinicPackage.CLIENT__CAPPOINTMENTS, null, msgs);
			if (newCAppointments != null)
				msgs = ((InternalEObject)newCAppointments).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ClinicPackage.CLIENT__CAPPOINTMENTS, null, msgs);
			msgs = basicSetCAppointments(newCAppointments, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ClinicPackage.CLIENT__CAPPOINTMENTS, newCAppointments, newCAppointments));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void makePayment(DentalClinic clinic) {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ClinicPackage.CLIENT__PREFERRED_DENTIST:
				return basicSetPreferredDentist(null, msgs);
			case ClinicPackage.CLIENT__CAPPOINTMENTS:
				return basicSetCAppointments(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ClinicPackage.CLIENT__NAME:
				return getName();
			case ClinicPackage.CLIENT__ADDRESS:
				return getAddress();
			case ClinicPackage.CLIENT__AGE:
				return new Integer(getAge());
			case ClinicPackage.CLIENT__DELTA_ID:
				return new Integer(getDeltaID());
			case ClinicPackage.CLIENT__CLIENT_TYPE:
				return getClientType();
			case ClinicPackage.CLIENT__EREFERENCE0:
				if (resolve) return getEReference0();
				return basicGetEReference0();
			case ClinicPackage.CLIENT__EREFERENCE1:
				if (resolve) return getEReference1();
				return basicGetEReference1();
			case ClinicPackage.CLIENT__EREFERENCE2:
				if (resolve) return getEReference2();
				return basicGetEReference2();
			case ClinicPackage.CLIENT__PREFERRED_DENTIST:
				return getPreferredDentist();
			case ClinicPackage.CLIENT__CAPPOINTMENTS:
				return getCAppointments();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ClinicPackage.CLIENT__NAME:
				setName((String)newValue);
				return;
			case ClinicPackage.CLIENT__ADDRESS:
				setAddress((String)newValue);
				return;
			case ClinicPackage.CLIENT__AGE:
				setAge(((Integer)newValue).intValue());
				return;
			case ClinicPackage.CLIENT__DELTA_ID:
				setDeltaID(((Integer)newValue).intValue());
				return;
			case ClinicPackage.CLIENT__CLIENT_TYPE:
				setClientType((ClientType)newValue);
				return;
			case ClinicPackage.CLIENT__EREFERENCE0:
				setEReference0((Client)newValue);
				return;
			case ClinicPackage.CLIENT__EREFERENCE1:
				setEReference1((Client)newValue);
				return;
			case ClinicPackage.CLIENT__EREFERENCE2:
				setEReference2((Client)newValue);
				return;
			case ClinicPackage.CLIENT__PREFERRED_DENTIST:
				setPreferredDentist((Dentist)newValue);
				return;
			case ClinicPackage.CLIENT__CAPPOINTMENTS:
				setCAppointments((Appointment)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eUnset(int featureID) {
		switch (featureID) {
			case ClinicPackage.CLIENT__NAME:
				setName(NAME_EDEFAULT);
				return;
			case ClinicPackage.CLIENT__ADDRESS:
				setAddress(ADDRESS_EDEFAULT);
				return;
			case ClinicPackage.CLIENT__AGE:
				setAge(AGE_EDEFAULT);
				return;
			case ClinicPackage.CLIENT__DELTA_ID:
				setDeltaID(DELTA_ID_EDEFAULT);
				return;
			case ClinicPackage.CLIENT__CLIENT_TYPE:
				setClientType(CLIENT_TYPE_EDEFAULT);
				return;
			case ClinicPackage.CLIENT__EREFERENCE0:
				setEReference0((Client)null);
				return;
			case ClinicPackage.CLIENT__EREFERENCE1:
				setEReference1((Client)null);
				return;
			case ClinicPackage.CLIENT__EREFERENCE2:
				setEReference2((Client)null);
				return;
			case ClinicPackage.CLIENT__PREFERRED_DENTIST:
				setPreferredDentist((Dentist)null);
				return;
			case ClinicPackage.CLIENT__CAPPOINTMENTS:
				setCAppointments((Appointment)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ClinicPackage.CLIENT__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case ClinicPackage.CLIENT__ADDRESS:
				return ADDRESS_EDEFAULT == null ? address != null : !ADDRESS_EDEFAULT.equals(address);
			case ClinicPackage.CLIENT__AGE:
				return age != AGE_EDEFAULT;
			case ClinicPackage.CLIENT__DELTA_ID:
				return deltaID != DELTA_ID_EDEFAULT;
			case ClinicPackage.CLIENT__CLIENT_TYPE:
				return clientType != CLIENT_TYPE_EDEFAULT;
			case ClinicPackage.CLIENT__EREFERENCE0:
				return eReference0 != null;
			case ClinicPackage.CLIENT__EREFERENCE1:
				return eReference1 != null;
			case ClinicPackage.CLIENT__EREFERENCE2:
				return eReference2 != null;
			case ClinicPackage.CLIENT__PREFERRED_DENTIST:
				return preferredDentist != null;
			case ClinicPackage.CLIENT__CAPPOINTMENTS:
				return cAppointments != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(", address: ");
		result.append(address);
		result.append(", age: ");
		result.append(age);
		result.append(", deltaID: ");
		result.append(deltaID);
		result.append(", clientType: ");
		result.append(clientType);
		result.append(')');
		return result.toString();
	}

} //ClientImpl
